import java.util.Arrays;

public class MyStsck {
    public int[] elem;
    public int usesize;

    public MyStsck() {
        this.elem = new int[10];
    }

    //入栈
    public void push(int val)
    {
        if(isfull())
        {
            elem= Arrays.copyOf(elem,2*elem.length);
        }
        elem[usesize]=val;
        usesize++;
    }

    public boolean isfull()
    {
        return usesize==elem.length;
    }

    //出栈
    public int pop()
    {
        if(isEmpty())
        {
            throw new EmptyException("栈为空");
        }
        usesize--;
        return elem[usesize];
    }
    public boolean isEmpty()
    {
        return usesize==0;
    }

    public int peek()
    {
        if(isEmpty())
        {
            throw new EmptyException("栈为空");
        }

        return elem[usesize-1];
    }



}
